import os
import zmq
from signal import signal, SIGTERM, SIGHUP

from dmqservice import DMQService
import znode


class DMQWorker(DMQService):

    def _suicide(self, exit_code=0):
        """docstring for _suicide"""
        logging.debug("DMQWorker._suicide(exit_code=%d)" % (exit_code,))
        super(DMQWorker, self)._suicide(exit_code)
    #_suicide()

    def _admin_app(self, msg, env):
        """docstring for _admin_rep"""
        logging.debug("DMQWorker._admin_app(msg:%s, env:%s)" % (msg, env))
    #_admin_app()

    def __init__(self, unix_socket_dir='/tmp/dmq_sockets'):
        """docstring for DMQWorker"""
        logging.debug("DMQWorker.__init__()")
        # Register our signal handlers
        super(DMQWorker, self).__init__(unix_socket_dir=unix_socket_dir)

        # Set up the admin socket
        logging.debug("DMQWorker.__init__() setting admin zmq socket on %s" %
                        (self.admin_worker_socket_path,))
        self._admin_znode = znode.znode(self._admin_app, type=zmq.REP,
                transport=znode.zmq_transport_IPC,
                endpoint=self.admin_worker_socket_path)
        self._znodes.append(self._admin_znode)
    # __init__()

#DMQWorker
